package com.hgt.cloudAlibaba.service.impl;

import com.hgt.cloudAlibaba.dao.AccountDao;
import com.hgt.cloudAlibaba.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * @author HuangGaoTao 929507053@qq.com
 * @Created: 2021/7/21 23:29
 */
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;


    /**
     * 扣减账户余额
     * */
    @Override
    public void decrease(Long userId, BigDecimal money) {
        log.info("------------------------》account-service中扣减账户余额开始");
        try {
            TimeUnit.SECONDS.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        accountDao.decrease(userId,money);
        log.info("----------------------------------》account-service中扣减账户余额结束");

    }
}
